#include<stdio.h>
#include<unistd.h>
#include<pthread.h>
pthread_mutex_t mutex;
void *thread_back(void *arg)
{
    int *pcount=(int*)arg;
    int i=0;

    while(i++<100000)
    {
        pthread_mutex_lock(&mutex);
        (*pcount)++;
        pthread_mutex_unlock(&mutex);
        usleep(1);
    }
}



int main()
{

    pthread_t threadid[10]={0};

    pthread_mutex_init(&mutex,NULL);
    int count=0;
    for(int i=0;i<10;i++)
    {
        pthread_create(&threadid[i],NULL,thread_back,&count);
    }


    for(int i=0;i<100;i++)
    {
        printf("counnt=%d\n",count);
        sleep(1);
    }


    return 0;
}
